//app.js
App({
  // onLaunch: function () {
  //   //调用API从本地缓存中获取数据
  //   var logs = wx.getStorageSync('logs') || []
  //   logs.unshift(Date.now())
  //   wx.setStorageSync('logs', logs)
  // },

  onLaunch: function () {
    //调用API从本地缓存中获取数据
    var logs = wx.getStorageSync('logs') || []
    logs.unshift(Date.now())
    wx.setStorageSync('logs', logs)
  },

  getUserInfo:function(cb){
    var that = this
    if(this.globalData.userInfo){
      console.log("---------------------")
      console.log(this.globalData.userInfo)
      typeof cb == "function" && cb(this.globalData.userInfo)
    }else{
      //调用登录接口
      wx.login({
        success: function () {
          wx.getUserInfo({
            success: function (res) {
              that.globalData.userInfo = res.userInfo
              typeof cb == "function" && cb(that.globalData.userInfo)
            }
          })
        }
      })
    }
  },
  globalData:{
    userInfo: null,
    foodList: [
      {
        id: 1,
        title: "白菜炒木耳",
        type: 1,
        cost: 0.1,
        desc: "原材料：白菜、木耳，清脆爽口。",
        // icon: "https://s1.ax1x.com/2023/06/01/p9xvae1.jpg",
        icon: "/res/img/bcme.jpg",
        num: 0
      },
      {
        id: 2,
        title: "松仁玉米",
        type: 1,
        cost: 0.1,
        desc: "没有松子用瓜子代替的，YYDS。",
        icon: "https://s1.ax1x.com/2023/06/01/p9xvDJO.jpg",
        num: 0
      }
	  //其他数据自行填充
      
    ]
    
  }
})